import Vue from 'vue'
import Vuex from './kVuex'

// 使用自定义vuex库,进行具体业务
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    name: '全局name',
    count: 1
  },
  mutations: {
    add(state) {
      state.count++
    }
  },
  actions: {
    add({ commit }) {
      setTimeout(() => {
        commit('add')
      }, 2000)
    }
  },
  getters: {
    doubleCount(state) {
      return state.count * 2
    }
  }
})
